class ProductProductunitprice {
  String? id;
  String? workshopId;
  String? factoryId;
  String? stationId;
  String? productId;
  String? unitprice;
  String? remark;
  String? active;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? workshopName;
  String? factoryName;
  String? stationName;
  String? productName;

  ProductProductunitprice({
    this.id,
    this.workshopId,
    this.factoryId,
    this.stationId,
    this.productId,
    this.unitprice,
    this.remark,
    this.active,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.factoryName,
    this.productName,
    this.stationName,
    this.workshopName,
  });

  ProductProductunitprice copyWith({
    String? id,
    String? workshopId,
    String? factoryId,
    String? stationId,
    String? productId,
    String? unitprice,
    String? remark,
    String? active,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductProductunitprice(
      id: id ?? this.id,
      workshopId: workshopId ?? this.workshopId,
      factoryId: factoryId ?? this.factoryId,
      stationId: stationId ?? this.stationId,
      productId: productId ?? this.productId,
      unitprice: unitprice ?? this.unitprice,
      remark: remark ?? this.remark,
      active: active ?? this.active,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductProductunitprice{
      id: id,
      workshopId: workshopId,
      factoryId: factoryId,
      stationId: stationId,
      productId: productId,
      unitprice: unitprice,
      remark: remark,
      active: active,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is ProductProductunitprice &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          workshopId == other.workshopId &&
          factoryId == other.factoryId &&
          stationId == other.stationId &&
          productId == other.productId &&
          unitprice == other.unitprice &&
          remark == other.remark &&
          active == other.active &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory ProductProductunitprice.fromMap(Map<String, dynamic> map) {
    return new ProductProductunitprice(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      workshopId: map['workshop_id'] != false
          ? map['workshop_id'][0].toString() as String?
          : "",
      workshopName: map['workshop_id'] != false
          ? map['workshop_id'][1].toString() as String?
          : "",
      factoryId: map['factory_id'] != false
          ? map['factory_id'][0].toString() as String?
          : "",
      factoryName: map['factory_id'] != false
          ? map['factory_id'][1].toString() as String?
          : "",
      stationId: map['station_id'] != false
          ? map['station_id'][0].toString() as String?
          : "",
      stationName: map['station_id'] != false
          ? map['station_id'][1].toString() as String?
          : "",
      productId: map['product_id'] != false
          ? map['product_id']["id"].toString() as String?
          : "",
      productName: map['product_id'] != false
          ? map['product_id']["name"].toString() as String?
          : "",
      unitprice: map['unitprice'] != false
          ? map['unitprice'].toString() as String?
          : "",
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      active: map['active'] != false ? map['active'].toString() as String? : "",
      createUid: map['create_uid'][1] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'][1] != false
          ? map['write_uid'][1].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshopId': this.workshopId,
      'factoryId': this.factoryId,
      'stationId': this.stationId,
      'productId': this.productId,
      'unitprice': this.unitprice,
      'remark': this.remark,
      'active': this.active,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.workshopId != null && this.workshopId != '')
        ['workshop_id', '=', this.workshopId],
      if (this.factoryId != null && this.factoryId != '')
        ['factory_id', '=', this.factoryId],
      if (this.stationId != null && this.stationId != '')
        ['station_id', '=', this.stationId],
      if (this.productId != null && this.productId != '')
        ['product_id', '=', this.productId],
    ] as List;
    if (list.length == 0) {
      list.add(['id', '!=', null]);
    }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshop_id': this.workshopId,
      'factory_id': this.factoryId,
      'station_id': this.stationId,
      'product_id': this.productId,
      'unitprice': this.unitprice,
      'remark': this.remark,
      'active': this.active,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
